--
-- Author: yawei.zhu
-- Date: 2018-09-18 11:09:55
--
-- DynastyMapModel
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ModelBase)

function ClassRef:ctor(data)
    self.super.ctor(self, data)
end

function ClassRef:init()
end

function ClassRef:isDynastyMap()
	local mapId = MapManager:getMapId()
	local mapConfig = GD:queryMapById(mapId)
	if mapConfig then
		local mapType = Enums.mapType[tonumber(mapConfig.maptype)]
		if mapType and mapType == "dynasty" then
			return true
		end
	end
	return false
end

------------------------ receive ------------------------


------------------------ request ------------------------
function ClassRef:reqDynastyInfo(townID)

	local function onGetDynastyTownInfo(townInfo)
		if not townInfo or townInfo.phase ~= "FIGHT" then return end
		app:sendMsg("DynastyMapController", "showMiniMap", townInfo)
		app:sendMsg("DynastyMapController", "showTopView", townInfo)
		app:sendMsg("DynastyMapController", "showRightView", townInfo)
		if BattleManager:isWaitBattle() or BattleManager:isBattle() then
			app:sendMsg("DynastyMapController", "hideDynastyMapView")
		end
	end

	local DynastyBattleModel = app:getInst("DynastyBattleModel")
	DynastyBattleModel:reqGetTownInfo(townID, onGetDynastyTownInfo)
end

return ClassRef
